#ifndef FACE_BEAUTY_CANVAS_H
#define FACE_BEAUTY_CANVAS_H

#include <list>
#include <QtGui/QImage>
#include <QtCore/QObject>
#include <QtWidgets/QWidget>
#include <QtMultimedia/QAbstractVideoSurface>

#include "image_filter_worker.h"
#include "lockfree_queue.h"

class FaceBeautyViewFinder:  public QAbstractVideoSurface
{
    Q_OBJECT
public:
    FaceBeautyViewFinder(ImageHandler* filter);
    ~FaceBeautyViewFinder();

    virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(
        QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const override;

    virtual bool present(const QVideoFrame &frame) override;
private:
    ImageHandler* handler_;
};

class FaceBeautyCanvas: public QWidget, public ImageHandler
{
    Q_OBJECT
public:
    explicit FaceBeautyCanvas(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
    virtual ~FaceBeautyCanvas();

    virtual int ProccessFrame(QImage* frame) override;

protected:
    void paintEvent(QPaintEvent *e) override;

private:
    dpl::LockfreeQueue<QImage*> images_;
};

#endif // FACE_BEAUTY_CANVAS_H
